package com.itcast.util;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;

import android.graphics.Bitmap;
import android.util.Log;
import android.widget.Toast;

public class Save {
	
	public static boolean storeImageToFile(Bitmap bitmap, String name){
         if(bitmap == null){
             return false;
         }
         File file=new File("/sdcard/"+name+".png");
	        try {
	            FileOutputStream out=new FileOutputStream(file);
	            if(bitmap.compress(Bitmap.CompressFormat.PNG, 100, out)){
	                out.flush();
	                out.close();
	            }
	        } catch (FileNotFoundException e) {
	            // TODO Auto-generated catch block
	            e.printStackTrace();
	        } catch (IOException e) {
	            // TODO Auto-generated catch block
	            e.printStackTrace();
	        }
	        return true;
	    }
}
